package com.can.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.can.constant.SystemConstants;
import com.can.convert.LinkConvert;
import com.can.domain.ResponseResult;
import com.can.domain.entity.Link;
import com.can.domain.vo.LinkVO;
import com.can.mapper.LinkMapper;
import com.can.service.LinkService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LinkServiceImpl extends ServiceImpl<LinkMapper, Link> implements LinkService {

    @Override
    public ResponseResult getAllLink() {
        //查询所有审核通过的
        LambdaQueryWrapper<Link> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Link::getStatus, SystemConstants.LINK_STATUS_NORMAL);
        List<Link> links = list(queryWrapper);
        //转换成vo
        List<LinkVO> linkVOS = LinkConvert.INSTANCE.convertList(links);
        //封装返回
        return ResponseResult.okResult(linkVOS);
    }
}
